package com.vanke.kotlin.domain

import java.util.*

/**
 * @name Kotlin
 * @package name：com.vanke.kotlin.domain
 * @class describe
 * @anthor shiyuchuan
 * @time 2017/7/21 9:41
 */
interface Command<T> {
    fun execute(): T
}



interface ForecastDataSource {
    fun requestForecastByZipCode(zipCode: Long, date: Long): ForecastList?
    fun requestDayForecast(id: Long): Forecast?
}


inline fun <T, R : Any> Iterable<T>.firstResult(predicate: (T) -> R?) :
        R {

    for(element in this){
        val result= predicate(element)
        if (result != null) return result
    }
    throw NoSuchElementException()
}